var ns, bmLocation;
app = new Vue({
    el: '#app',
    data: {
        list: [],
        form: {
            pageindex: 0,
            pagesize: 10,
        },
        can_scroll:false,
    },
    methods: {
        get_data: function () {
            var that = this;
            that.can_scroll = false;
            var options = {};
            options.action = "getservicecardcollection";
            options.pagesize = that.form.pagesize;
            options.pageindex = that.form.pageindex;
            ns.post(options, function (succeed, data, err) {
                if (succeed) {
                    if (data.data.length == that.form.pagesize) {
                        that.can_scroll = true;
                    }
                    if (that.form.pageindex == 0) {
                        that.list = data.data;
                    } else {
                        that.list = that.list.concat(data.data);
                    }
                    app.current_item_length = that.list.length
                } else if (err) {
                    // that.list = [];
                    that.current_item_length = 0;
                    api.toast({
                        msg: err,
                        duration: 2000,
                        location: 'bottom'
                    });
                }
            }, {
                toast: true
            });
        },
        //记录详情
        do_opendetail:function(id){
            var that=this;
            ns.openWin('service_history_detail', '收款详情',{
                ID:id
            });

        },
        //扫码收款
        // do_opensaoma:function(){
        //     var that=this;
        //     ns.openWin('service_saoma_add', '新增收款');
        // },
        
        //手动收款
        do_openwrite:function(){
            var that=this;
            ns.openWin('service_write_add', '新增收款');
        },

        do_opensaoma: function (item) {
            var that = this;
            ns.confirmPer('camera', function () {
                setTimeout(function () {
                    that.do_open_scan_login_start();
                }, 200)
            })
        },
        do_open_scan_login_start: function () {
            var that = this;
            ns.openFrame('scanner_frm', {
                type: 0
            });
        },

    }
});
apiready = function () {
    api.parseTapmode();
    ns = window.Foresight.Util;
    app.get_data();
    api.addEventListener({
        name: 'home_new_updata'
    }, function(ret, err) {
        app.get_data();
    });

};
